package shop.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import shop.dao.IShopcartDao;
import shop.model.Shopcart;

@Service
public class ShopcartServiceImpl implements IShopcartService {
	
	@Resource
	private IShopcartDao dao;

	@Override
	public int add(Shopcart cart) {
		//判断要添加的商品是不是已经在顾客的购物车中了
		int n = dao.findCart(cart);
		if(n>0) {//如果有，改数量
			n = dao.editCart(cart);
		}else {//如果没有，添加
			n = dao.add(cart);
		}
		return n;
	}

}
